/********************幻灯片触屏********************/
$(function () {
        femovepic.init({
            initNum: 0,           //默认显示哪一张
            id: '#tec-sli-img-container',     //图片box id
            space: 8,            //滑动间距多少即响应（敏感度）
            moveTime: 500,        //滑动时间
            play: true,           //是否自动播放
            playTime: 6000        //播放时间间隔
        });
    });




;(function(global, factory){

	/*
     * 鏄惁 amd 鎴栬€� cmd寮曞叆
	 */

	if ( typeof module === "object" && module && typeof module.exports === "object" ) {
	    module.exports = global.document ?
			factory( global, true ) :
			function( w ) {
				if ( !w.document ) {
					throw new Error( "femovepic requires a window with a document" );
				}
				return factory( w );
			};
	} else if(typeof define === "function") {
	    if (  define.amd || define.cmd ) {
	        define(function () { return factory( global ); } );
	    }
	}else{
	    factory( global );
	}

})(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {

	var $ = window.Zepto;

	/*
	 * 瀛樺偍宸茬敤鍛藉悕绌洪棿femovepic && 宸插瓨鍦╢emovepic鍗宠繑鍥�
	 */
	try{
		var _femovepic = window.femovepic;

		if(_femovepic.id === "femovepic-by-gedy"){
			return _femovepic;
		}
	}catch(e){}
	
	var Femovepic = function(){
		this.version = "0.0.3";
		this.id = "femovepic-by-gedy";
		this.playInter = null;
		this.status = {
			current : 0,
			len: 0,
			startX: 0,
			endX: 0
		};
	}

	Femovepic.prototype.init = function(opt){
		var settings = {
			initNum:0,
			id: '',
			space: 10,
			moveTime: 300,
			play: false,
			playTime: 3000
		}

		settings = $.extend(settings, opt);

		this.settings = settings;

		this.show();
		this.eventFunc();
		this.autoPlay();
	}

	Femovepic.prototype.autoPlay = function(){
		var pointer = this,
			settings = this.settings;

		if(!settings.play){
			return false;
		}

		try{
			clearInterval(this.playInter);
			this.playInter = setInterval(function(){
				pointer.slide('left');
			}, settings.playTime)
		}catch(e){}
	}

	Femovepic.prototype.stopPlay = function(){
		try{
			clearInterval(this.playInter);
		}catch(e){}
	}

	/*
	 * 鍒濆鍖栨樉绀�
	 */
	Femovepic.prototype.show = function(){
		var settings = this.settings,
			$id = $(settings.id),
			$img = $id.find('img').eq(0),
			$nav = null,
			imgH = 0,
			nav_str = '',
			setBoxHeight = function(){
				imgH = parseInt($img.css('height')) || 0;
				$id.css('height', imgH);
				$id.find('li').css('height', imgH);	
			}

		this.status.current = settings.initNum;
		this.status.len = $id.find('li').length;

		nav_str = '<p id="feMovePic_nav" class="feMovePic_nav">';
		for(var i = 0, len = this.status.len; i < len; i++){
			nav_str = nav_str + '<span>'+ (i + 1) +'</span>';	
		}
		nav_str = nav_str + '</p>';	

		$id.append(nav_str);

		$nav = $('#feMovePic_nav');

		$id.find('li').eq(settings.initNum).css('left', 0).addClass('current');
		$nav.find('span').eq(settings.initNum).addClass('current');
		$id.show();

		setBoxHeight();

		$(window).resize(setBoxHeight);
	}

	Femovepic.prototype.eventFunc = function(){
		var pointer = this,
			settings = this.settings;

		$(settings.id).on('touchstart', function(event){

			if(pointer.canMove()){
				var touch = event.touches[0];
				pointer.status.startX = touch.pageX;
			}

			pointer.stopPlay();

		}).on('touchmove', function(event){

			if(pointer.canMove()){
				var touch = event.touches[0];
				pointer.status.endX = touch.pageX;
				event.preventDefault();
			}
			
		}).on('touchend', function(event){

			if(pointer.canMove()){
				pointer.move(pointer.status.endX - pointer.status.startX);
			}

			pointer.autoPlay()
			
		})
	}

	Femovepic.prototype.canMove = function(){
		var settings = this.settings,
			$id = $(settings.id);

		if($id.hasClass('sliding')){
			return false;
		}else{
			return true;
		}
	}

	Femovepic.prototype.move = function(space){
		var settings = this.settings,
			xSpace = parseInt(space) || 0,
			direction = '';

		if(Math.abs(xSpace) < space){
			return false;
		}else{
			if(xSpace < 0){
				direction = 'left';
			}else{
				direction = 'right';
			}
			this.slide(direction);
		}
	}

	Femovepic.prototype.slide = function(direction){
		var settings = this.settings,
			direc = direction,
			moveTime = settings.moveTime,
			current = this.status.current,
			next = current,
			len = this.status.len,
			$id = $(settings.id),
			$nav = $('#feMovePic_nav'),
			$li = $id.find('li'),
			$current = $li.eq(current),
			$next = null;

		if($id.hasClass('sliding')){
			return false;
		}

		if(direc === 'left'){

			if(typeof $current.animate == 'undefined'){

				if(current < len - 1){
					next = current + 1;
				}else{
					next = 0;
				}
				$li.css('left', '100%').eq(next).css('left', 0);

			}else{

				if(current < len - 1){
					next = current + 1;
				}else{
					next = 0;
				}

				$next = $li.eq(next);

				$id.addClass('sliding');
				$li.css('left', '200%');
				$next.css('left', '100%');
				$current.css('left', 0);

				$next.animate({
					left: '0'
				}, moveTime - 50, 'ease-out', function(){
					$id.removeClass('sliding');
				})

				$current.animate({
					left: '-100%'
				}, moveTime, 'ease-out')
			}
		}else{

			if(typeof $current.animate == 'undefined'){

				if(current <= 0){
					next = len - 1;
				}else{
					next = current - 1;
				}
				$li.css('left', '-100%').eq(next).css('left', 0);

			}else{

				if(current <= 0){
					next = len - 1;
				}else{
					next = current - 1;
				}

				$next = $li.eq(next);

				$id.addClass('sliding');
				$li.css('left', '-200%');
				$next.css('left', '-100%');
				$current.css('left', 0);

				$next.animate({
					left: '0'
				}, moveTime - 50, 'ease-out', function(){
					$id.removeClass('sliding');
				})

				$current.animate({
					left: '100%'
				}, moveTime, 'ease-out')
			}
		}

		$li.removeClass('current').eq(next).addClass('current');
		$nav.find('span').removeClass('current').eq(next).addClass('current');

		this.status.current = next;

	}

	/*
	 * 鑷畾涔夊悕瀛椾互鍙婁笉浣跨敤femovepic鍛藉悕绌洪棿
	 */
	Femovepic.prototype.noConflict = function(){
		window.femovepic = _femovepic;
		return new Femovepic();
	}

	var femovepic = new Femovepic();

	if ( typeof noGlobal === typeof undefined ) {
		window.femovepic = femovepic;
	}

	return femovepic;
})




/********************幻灯片轮播********************/
    var i = 1;

    $(function () {
        $("#tec-sli-img-container").find("a").click(function () {
            $("#tec-sli-img").attr("src", $(this).attr("url"));
            $("#tec-sli-img-container").find("a").removeClass("ban-nav-click");
            $(this).addClass("ban-nav-click");
            i = parseInt($(this).attr("num"));
        });

        window.setInterval(function () {
            var obj = $("#tec-sli-img-container").find("a[num=" + i.toString() + "]");

            $("#tec-sli-img").attr("src", $(obj).attr("url"));
            $("#tec-sli-img-container").find("a").removeClass("ban-nav-click");
            $(obj).addClass("ban-nav-click");
            i = i + 1;

            if (i > 5) {
                i = 1;
            }
        }, 3000);
    });

     var mySwiper = new Swiper('.swiper-container',{
        pagination: '.pagination',
        loop:true,
        grabCursor: true,
        autoplay:3000,
        autoplayDisableOnInteraction:false,
        paginationClickable: true
      })
      $('.arrow-left').on('click', function(e){
        e.preventDefault()
        mySwiper.swipePrev()
      })
      $('.arrow-right').on('click', function(e){
        e.preventDefault()
        mySwiper.swipeNext()
      })